package cn.com.waajyun.shanbayscan.dto;

import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang3.StringUtils;

public class AuthorDto {

    @JSONField(name = "avatar")
    private String avatar;
    @JSONField(name = "id")
    private String id;
    @JSONField(name = "nickname")
    private String nickname;
    @JSONField(name = "username")
    private String username;
    private boolean isUpdated;

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public void updateNickName(String nickname) {
        if(isUpdated) {
            if(StringUtils.isBlank(this.nickname) && StringUtils.isNotBlank(nickname)) {
                throw new RuntimeException("数据错误，请联系管理员 ！");
            } else if(!this.nickname.equals(nickname)) {
                throw new RuntimeException("数据错误，请联系管理员 ！");
            }
        }
        this.nickname = nickname;
        this.isUpdated = true;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public boolean isUpdated() {
        return isUpdated;
    }

    public void setUpdated(boolean updated) {
        isUpdated = updated;
    }
}
